<div class="websearch_settings">
    <div class="inline-drawer">
        <div class="inline-drawer-toggle inline-drawer-header">
            <b>Web Search</b>
            <div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
        </div>
        <div class="inline-drawer-content">
            <div class="flex-container flexFlowColumn">
                <label class="checkbox_label" for="websearch_enabled">
                    <input type="checkbox" id="websearch_enabled" />
                    <span>Enabled</span>
                </label>
                <h4>Source</h4>
                <select id="websearch_source">
                    <option value="serpapi">SerpApi</option>
                    <option value="searxng">SearXNG</option>
                    <option value="extras">Extras API</option>
                    <option value="plugin">Selenium Plugin</option>
                </select>
                <div id="serpapi_settings">
                    <div class="flex-container alignItemsBaseline">
                        <h4 for="serpapi_key" class="flex1 margin0">
                            <a href="https://serpapi.com/" target="_blank">SerpApi Key</a>
                        </h4>
                        <div id="serpapi_key" class="menu_button menu_button_icon">
                            <i class="fa-solid fa-key"></i>
                            <span>Click to set</span>
                        </div>
                    </div>
                </div>
                <div id="websearch_searxng_settings">
                    <div>
                        <strong>
                            <a href="https://github.com/searxng/searxng">SearXNG <i class="fa-brands fa-github"></i></a>
                        </strong>
                    </div>
                    <label for="websearch_searxng_url">Base URL</label>
                    <input type="text" class="text_pole" id="websearch_searxng_url" value="">
                </div>
                <div id="websearch_extras_settings">
                    <label for="websearch_extras_engine">Engine</label>
                    <select id="websearch_extras_engine">
                        <option value="google">Google</option>
                        <option value="duckduckgo">DuckDuckGo</option>
                    </select>
                </div>
                <label for="websearch_cache_lifetime">Cache Lifetime <small>(seconds)</small></label>
                <input type="number" class="text_pole" id="websearch_cache_lifetime" value="">
                <hr>
                <h4>Prompt Settings</h4>
                <label for="websearch_budget">Prompt Budget <small>(text characters)</small></label>
                <input type="number" class="text_pole" id="websearch_budget" value="">
                <label for="websearch_template">Insertion Template</label>
                <textarea id="websearch_template" class="text_pole textarea_compact autoSetHeight" rows="2" placeholder="Use {{query}} and {{text}} macro."></textarea>
                <label for="websearch_position">Injection Position</label>
                <div class="radio_group">
                    <label>
                        <input type="radio" name="websearch_position" value="2" />
                        Before Main Prompt / Story String
                    </label>
                    <!--Keep these as 0 and 1 to interface with the setExtensionPrompt function-->
                    <label>
                        <input type="radio" name="websearch_position" value="0" />
                        After Main Prompt / Story String
                    </label>
                    <label>
                        <input type="radio" name="websearch_position" value="1" />
                        In-chat @ Depth <input id="websearch_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
                    </label>
                <hr>
                <h4>Search Activation</h4>
                <label class="checkbox_label" for="websearch_use_backticks">
                    <input type="checkbox" id="websearch_use_backticks" />
                    <span>Use `Backticks`</span>
                </label>
                <label class="checkbox_label" for="websearch_use_regex">
                    <input type="checkbox" id="websearch_use_regex" />
                    <span>Use Regex</span>
                </label>
                <div id="websearch_regex_block" class="flex flexFlowColumn">
                    <label>Regex Rules</label>
                    <div class="menu_button menu_button_icon" id="websearch_regex_add" title="Create a new regex rule">
                        <i class="fa-solid fa-plus"></i>
                        <span>Add Regex</span>
                    </div>
                    <div id="websearch_regex_list" class="wide100p flex-container flexFlowColumn"></div>
                </div>
                <label class="checkbox_label" for="websearch_use_trigger_phrases">
                    <input type="checkbox" id="websearch_use_trigger_phrases" />
                    <span>Use Trigger Phrases</span>
                </label>
                <div id="websearch_trigger_phrases_block" class="flex-container flexFlowColumn">
                    <label for="websearch_trigger_phrases">Trigger Phrases <small>(one per line)</small></label>
                    <small>If a message starts with a period, it will be ignored.</small>
                    <textarea id="websearch_trigger_phrases" class="text_pole textarea_compact" rows="4"></textarea>
                    <label for="websearch_max_words">Max Words <small>(per query)</small></label>
                    <input type="number" class="text_pole" id="websearch_max_words" value="" min="1" max="32" step="1">
                </div>
                <hr>
                <h4>Page Scraping</h4>
                <label class="checkbox_label" for="websearch_visit_enabled">
                    <input type="checkbox" id="websearch_visit_enabled" />
                    <span>Visit Links</span>
                </label>
                <div class="marginTopBot5">
                    Text will be extracted from the visited search result pages and saved to:
                </div>
                <label for="websearch_visit_target_message" class="checkbox_label">
                    <input id="websearch_visit_target_message" type="radio" name="websearch_visit_target" value="0" />
                    <span>Message attachment</span>
                </label>
                <label for="websearch_visit_target_databank" class="checkbox_label">
                    <input id="websearch_visit_target_databank" type="radio" name="websearch_visit_target" value="1" />
                    <span>Data Bank (chat)</span>
                </label>
                <label for="websearch_visit_count">Visit Count <small>(max per query)</small></label>
                <input type="number" class="text_pole" id="websearch_visit_count" value="" min="0" max="10" step="1">
                <label for="websearch_visit_blacklist">Visit Domain Blacklist <small>(one per line)</small></label>
                <textarea id="websearch_visit_blacklist" class="text_pole textarea_compact" rows="4"></textarea>
                <label for="websearch_file_header">File Header</label>
                <textarea id="websearch_file_header" class="text_pole textarea_compact autoSetHeight" rows="2" placeholder="Use &lcub;&lcub;query&rcub;&rcub; macro."></textarea>
                <label for="websearch_block_header">Block Header</label>
                <textarea id="websearch_block_header" class="text_pole textarea_compact autoSetHeight" rows="2" placeholder="Use &lcub;&lcub;link&rcub;&rcub; and &lcub;&lcub;text&rcub;&rcub; macros."></textarea>
                </div>
            </div>
        </div>
    </div>
</div>
